package com.swu.pojo;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
private static SessionFactory factory;
	static {
		try {
			Configuration cfg = new Configuration();
			factory = cfg.configure().buildSessionFactory();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public static Session openSession() {
		return factory.openSession();
	}

	public static void coloseSession(Session ss) {
		if (null != ss) {
			if (ss.isOpen()) {
				ss.close();
			}
		}
	}

}
